<?php
class AdminRssNewController extends AdminIndexController
{
    public function getTemplateName()
    {
        return 'AdminRssEdit.tpl';
    }
    
    public function prepare()
    {
        ApplicationController::attachEventListener($this, array($_POST, 'RssSaveAction'));
    }
    
    public function exec()
    {
        $response = array(
            'error' => 1,
            'text'  => 'При попытке сохранения произошла ошибка'
        );
        
        $url    = Env::post('url');
        $status = Env::post('status');
        
        $rss_model = new RssModel(DbConnection::COMMON_SPACE, true);
        
        if ($rss_model->add($url, $status)) {
            $response['error'] = 0;
            $response['text']  = '';
        }
        
        echo json_encode($response);
        die();
    }
}